Conditional Rendering in React Complete Guide with Examples 2026

Image
  Conditional Rendering in React Conditional Rendering is one of the most useful concepts in React. It means showing different content on the screen depending on a condition. For example: If a user is logged in → show Logout If a user is not logged in → show Login If a student has passed → show Congratulations If a product is available → show Buy Now If data is loading → show Loading... React does not have a separate if rendering tag. Instead, we use normal JavaScript conditions such as if, the ternary operator, &&, and switch to decide what should appear in the UI.

Write C Program to Print Inverted Half Pyramid of Stars Pattern

 

Write C Program to Print  Inverted Half Pyramid of Stars  Pattern

Write C Program to Print  Inverted Half Pyramid of Stars  Pattern

Example 


#include<stdio.h>


void main ()

{

int i,j,r;


printf("enter the number");

scanf("%d",&r);

for(i=r;i>=1;i--)

{


for(j=1;j<=i;j++)

{

printf("*");

}

printf("\n");

}

return 0;

}


Write C Program to Print  Inverted Half Pyramid of Stars  Pattern

Explain Program

Step :1

#include <stdio.h>

  • standard input-output library, printf() and scanf() function

Step :2

void main()

  • starting point of the program.

Step :3

. int i, j, r;

  • Declares three integer variables:
  • r: the number of rows (input from the user).
  • i: used for the outer loop (rows).
  • j: used for the inner loop (columns/asterisks per row).

Step :4

printf("enter the number");

scanf("%d", &r);

  •  user to enter the number of rows for the triangle.

Step :5

for(i = r; i >= 1; i--)

  • Starts at i = r and decrements to 1.
  • First row has r stars,
  • Second row has r-1 stars,

Step :6

for(j = 1; j <= i; j++)

{

    printf("*");

}

  • row, prints i number of asterisks (*).
The number of asterisks decreases as i decreases

Step :7

printf("\n");

  •  cursor to the next line after each row of asterisks.

Step :8

return 0;

Write C Program to Print  Inverted Half Pyramid of Stars  Pattern
 Program Output :- 

Write C Program to Print  Inverted Half Pyramid of Stars  Pattern


Related Post :-


Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example